<?php

function reequipment_user_report_pm_by_machine()
{  
	if (!xarVarFetch('equipment_id', 'int:1:', $equipment_id, '', XARVAR_NOT_REQUIRED)) return;  
	if (!xarVarFetch('model_id', 'int:1:', $model_id, '', XARVAR_NOT_REQUIRED)) return;  
    if (!xarVarFetch('area_id', 'int:1:', $area_id, '', XARVAR_NOT_REQUIRED)) return;
    xarTplSetPageTitle(xarML('PM By Machine Report'));
    if (!xarSecurityCheck('EditEquipment', 1)) return;
    $data = array();
     // Get company_id
    if (!xarVarFetch('company_id', 'int:1:', $company_id, '', XARVAR_NOT_REQUIRED)) return; 
	if (!xarModAPIFunc('reequipment', 'user', 'getcompanyid', array('company_id_from_url' => $company_id))) return;
	$company_id = xarSessionGetVar('company_id');
	
	// Get PM Data
	$data['pms'] = xarModAPIFunc('reequipment', 'user', 'getschedule', array('model_id' => $model_id, 'area_id' => $area_id, 'or' => true));
	// return var_export($data['pms']);
	
    // Model Name
	$equipment = xarModAPIFunc('reequipment', 'user', 'getequipment', array('equipment_id' => $equipment_id));
	foreach($equipment as $var){
		$data['model_name'] = $var['model_name'];
	}
    return $data;
}

?>